<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>get 和 set</title>
</head>
<body>
<div id="app">
  {{fullName}}
</div>

<script src="../vue.global.js"></script>
<script>
  const App = {
    data(){
      return {
        count: 100,
        firstName: 'Mr.',
        lastName: 'Huang'
      }
    },
    computed: {
      fullName: {
        get(){
          console.log('get')
          return this.firstName + this.lastName
        },
        set(value){
          // console.log(value)
          console.log('set')
          const str = value.split('.')
          this.firstName = str[0] + '.'
          this.lastName = str[1]
        }
      }
    }
  }

  const vm = Vue.createApp(App).mount('#app');
  // vm.fullName = "Miss.Zhang"
</script>
</body>
</html>
